﻿/// <reference path='../typings/jquery/jquery.d.ts'/>
/// <reference path="app.ts" />

import Routing = Sustainalytics.Routing;

appRoot.config([Routing.routingServiceName + 'Provider', '$httpProvider', (routingProvider: Sustainalytics.Routing.IRoutingServiceProvider, $httpProvider) => {


    $httpProvider.interceptors.push(Sustainalytics.Authentication.authenticationHttpInterceptorName);

    routingProvider
        .when('/accounts',
        {
            templateUrl: 'views/Accounts/Accounts.html', controller: 'AccountsController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/account/:accountId', {
            templateUrl: 'views/Accounts/AccountDetails.html', controller: 'AccountDetailsController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/users', {
            templateUrl: 'views/Users/Users.html', controller: 'UsersController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/user/:userId', {
            templateUrl: 'views/Users/UserDetails.html', controller: 'UserDetailsController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/news/add', {
            templateUrl: 'views/News/NewsAdd.html', controller: 'NewsAddController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/news/edit/:id', {
            templateUrl: 'views/News/NewsEdit.html', controller: 'NewsEditController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/news', {
            templateUrl: 'views/News/NewsList.html', controller: 'NewsListController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/events', {
            templateUrl: 'views/Events/EventsList.html', controller: 'EventsListController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/events/add', {
            templateUrl: 'views/Events/EventAddEdit.html', controller: 'EventAddEditController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/events/edit/:id', {
            templateUrl: 'views/Events/EventAddEdit.html', controller: 'EventAddEditController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/insights', {
            templateUrl: 'views/Insights/InsightList.html', controller: 'InsightsListController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/insights/add', {
            templateUrl: 'views/Insights/InsightAddEdit.html', controller: 'InsightsAddEditController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/insights/edit/:id', {
            templateUrl: 'views/Insights/InsightAddEdit.html', controller: 'InsightsAddEditController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/esgratings', {
            templateUrl: 'views/Tools/EsgRatings.html', controller: 'ToolsController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/universes', {
            templateUrl: 'views/Tools/universes.html', controller: 'UniversesController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/claims', {
            templateUrl: 'views/Tools/claims.html', controller: 'ToolsController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/productinvolvement', {
            templateUrl: 'views/ProductInvolvement/ProductInvolvement.html', controller: 'PIInputFileController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/weightMatricesUpload', {
            templateUrl: 'views/ESGRatings/WeightMatricesUpload.html', controller: 'WeightMatricesController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/weightMatricesDownload', {
            templateUrl: 'views/ESGRatings/WeightMatricesDownload.html', controller: 'WeightMatricesController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/testesgratings', {
            templateUrl: 'views/ESGRatings/TestESGRatings.html', controller: 'TestESGRatingsController'
        },
        new Routing.RouteSecurity().addAdminResource())
        .when('/esgProfile', {
            templateUrl: 'views/ESGRatings/EsgProfile.html', controller: 'ESGProfileController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/referenceUniverses', {
            templateUrl: 'views/ESGRatings/referenceUniverses.html', controller: 'ReferenceUniversesController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/keyESGIssuesUpload', {
            templateUrl: 'views/ESGRatings/KeyESGIssuesUpload.html', controller: 'KeyESGIssuesController'
        },
        new Routing.RouteSecurity().addAdminResource())

        .when('/forgotPassword', {
            templateUrl: 'views/Login/ForgotPassword.html', controller: Sustainalytics.Authentication.accountControllerName
        }, new Routing.RouteSecurity().setLogout(true))

        .when('/forgotPasswordConfirmation', {
            templateUrl: 'views/Login/ForgotPasswordConfirmation.html', controller: Sustainalytics.Authentication.accountControllerName
        }, new Routing.RouteSecurity().setLogout(true))

        .when('/changePassword/:user?/:tempKey?', {
            templateUrl: 'views/Login/ChangePassword.html', controller: Sustainalytics.Authentication.accountControllerName
        }, new Routing.RouteSecurity().setLogout(true))

        .when('/passwordExpired', {
            templateUrl: 'views/Login/PasswordExpired.html', controller: Sustainalytics.Authentication.accountControllerName
        }, new Routing.RouteSecurity().setLogout(true))

        .when('/lrtmtest', {
            templateUrl: '/views/LongRunningTaskManagerTest.html', controller: 'LongRunningTaskManagerTestController'
        })

        .when('/login', {
            templateUrl: 'views/Login/Login.html', controller: Sustainalytics.Authentication.accountControllerName
        }, new Routing.RouteSecurity().setLogout(true))

        .when('/governancereports', {
            templateUrl: 'views/GovernanceReports/CompanySearch.html', controller: Sustainalytics.GovernanceReports.companyControllerName
        })

        .when('/governancereports/:id', {
        templateUrl: 'views/GovernanceReports/CompanyView.html', controller: Sustainalytics.GovernanceReports.CompanyViewController
        })

        .otherwise({ redirectTo: '/accounts' },
            new Routing.RouteSecurity().addAdminResource());
}]);

appRoot.run(['notificationFactory', '$location',  '$rootScope', (notificationFactory: INotificationFactory, $location, $rootScope) => {

    //$rootScope.reportNotification = { Created: null, Error: null, FilePath: null, Finished: null, ReportType: null, Status: null };
}]);